<html>
<head><meta charset="utf-8"><title>syntax ptr crash · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html">syntax ptr crash</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="193242619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193242619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193242619">(Apr 07 2020 at 20:24)</a>:</h4>
<p>This has been a long time I have been seeing this damn crash:</p>
<div class="codehilite"><pre><span></span>thread &#39;&lt;unnamed&gt;&#39; panicked at &#39;can&#39;t resolve local ptr to SyntaxNode: SyntaxNodePtr { range: [1170; 1322), kind: ENUM_DEF }&#39;, crates/ra_syntax/src/ptr.rs:30:28
stack backtrace:
   0: &lt;unknown&gt;
   1: &lt;unknown&gt;
   ... //  50+ lines of unknown
   note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace
</pre></div>


<p>Even though I have <code>RUST_BACKTRACE=full</code> set in my <code>.profile</code> and it is clearly in my env wherever I check, but the stacktrace shows <code>unknown</code> for some reason. <span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span>  do you have any ideas on how to get some payload from this error?</p>



<a name="193243173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193243173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Emil Lauridsen <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193243173">(Apr 07 2020 at 20:28)</a>:</h4>
<p>You need to enable debug symbols in the release build profile (add <code>debug = true</code> to debug section of cargo.toml)</p>



<a name="193243387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193243387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193243387">(Apr 07 2020 at 20:30)</a>:</h4>
<p>Ah, I wish nightly build included debug symbols, because this error happens rarely and I cannot reproduce it ...</p>



<a name="193245823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193245823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193245823">(Apr 07 2020 at 20:48)</a>:</h4>
<p>You don't need the debug sections for symbol names in the backtrace. You only need an unstripped binary. The backtrace is generated using <code>.eh_frame</code> (necessary for panic=unwind) and the symbol table. Debuginfo only gives you the file and line of the error.</p>



<a name="193249099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193249099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193249099">(Apr 07 2020 at 21:11)</a>:</h4>
<p>Okay, so how do I enable the stacktrace in Cargo.toml in the better way  <span class="user-mention" data-user-id="133247">@bjorn3</span>?</p>



<a name="193249694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193249694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193249694">(Apr 07 2020 at 21:16)</a>:</h4>
<p>If you don't explicitly strip the binary, <code>RUST_BACKTRACE</code> should work just fine. CI does run strip binaries: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/d89c189ad1efe87e54855e6488184d7a3825a534/xtask/src/dist.rs#L63" title="https://github.com/rust-analyzer/rust-analyzer/blob/d89c189ad1efe87e54855e6488184d7a3825a534/xtask/src/dist.rs#L63">https://github.com/rust-analyzer/rust-analyzer/blob/d89c189ad1efe87e54855e6488184d7a3825a534/xtask/src/dist.rs#L63</a> so backtraces don't work for releases build on CI.</p>



<a name="193254136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193254136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193254136">(Apr 07 2020 at 22:03)</a>:</h4>
<p>Hmm, you are right, maybe we shouldn't strip the binary at least for nightlies?</p>



<a name="193254276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193254276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193254276">(Apr 07 2020 at 22:04)</a>:</h4>
<p>Does it give a big performance increase?</p>



<a name="193254969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193254969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193254969">(Apr 07 2020 at 22:13)</a>:</h4>
<p>Stripping should only affect binary size.</p>



<a name="193255948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193255948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193255948">(Apr 07 2020 at 22:26)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> your word against?</p>



<a name="193262554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193262554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193262554">(Apr 07 2020 at 23:52)</a>:</h4>
<p>As aside: I suspect <a href="https://gist.github.com/Veetaha/7c1dc7823ede84349e5ee7654db65f80" title="https://gist.github.com/Veetaha/7c1dc7823ede84349e5ee7654db65f80">this crash</a> happens when you change the code in libraries (i.e. code from <a href="http://crates.io" title="http://crates.io">crates.io</a>) and then when the auto-import is triggered you get stale symbols from <a href="https://github.com/rust-analyzer/rust-analyzer/blob/d89c189ad1efe87e54855e6488184d7a3825a534/crates/ra_ide_db/src/symbol_index.rs#L91" title="https://github.com/rust-analyzer/rust-analyzer/blob/d89c189ad1efe87e54855e6488184d7a3825a534/crates/ra_ide_db/src/symbol_index.rs#L91"><code>SymbolsDatabase::library_symbols()</code></a> and the syntax ptr that previously referred to some struct or enum no longer resolves. I think this might be connected with <a href="https://github.com/rust-analyzer/rust-analyzer/blob/d89c189ad1efe87e54855e6488184d7a3825a534/crates/ra_ide_db/src/change.rs#L209-L213" title="https://github.com/rust-analyzer/rust-analyzer/blob/d89c189ad1efe87e54855e6488184d7a3825a534/crates/ra_ide_db/src/change.rs#L209-L213"><code>Durability::HIGH</code></a> that we set for library symbols, i.e. maybe this is a <code>salsa</code> bug, or what is more likely we messed up the inputs durability and they don't invalidate the <code>library_symbols()</code> query...</p>



<a name="193262582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193262582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193262582">(Apr 07 2020 at 23:53)</a>:</h4>
<p><a href="/user_uploads/4715/AQg5Mg_yXWIkJs3Auw1M8ZcC/panic.gif" title="panic.gif">panic.gif</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/AQg5Mg_yXWIkJs3Auw1M8ZcC/panic.gif" title="panic.gif"><img src="/user_uploads/4715/AQg5Mg_yXWIkJs3Auw1M8ZcC/panic.gif"></a></div>



<a name="193273299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/syntax%20ptr%20crash/near/193273299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/syntax.20ptr.20crash.html#193273299">(Apr 08 2020 at 03:52)</a>:</h4>
<p>I don't think that's supposed to work. We assume that the dependencies don't change, as far as I know.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>